package com.xiashitech.agent.instrumentation.base.context;

import io.opentelemetry.javaagent.shaded.io.opentelemetry.api.baggage.BaggageEntry;
import io.opentelemetry.javaagent.shaded.io.opentelemetry.api.baggage.BaggageEntryMetadata;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.ToString;

import javax.annotation.concurrent.Immutable;

@Immutable
@Getter
@EqualsAndHashCode
@ToString
public class ImmutableEntry implements BaggageEntry {
    private String value;
    private BaggageEntryMetadata metadata;
    ImmutableEntry(String value, BaggageEntryMetadata metadata) {
        if (value == null) {
            throw new NullPointerException("Null value");
        }
        if (metadata == null) {
            throw new NullPointerException("Null metadata");
        }
        this.value = value;
        this.metadata = metadata;
    }
    static ImmutableEntry create(String value, BaggageEntryMetadata entryMetadata) {
        return new ImmutableEntry(value, entryMetadata);
    }
}
